﻿ 
@using System.Globalization
@using LERP.Web.App_Start
@using Sharp.Framework
@using Sharp.Framework.Extensions

@model MvcContrib.Pagination.IPagination<LERP.Domain.Bug>
@{
    ViewBag.Title = "问题列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var statusList= new List<SelectListItem> {new SelectListItem {Text = "未处理", Value = "0"}, new SelectListItem {Text = "已解决", Value = "1"}, new SelectListItem {Text = "保留现状", Value = "2"}, new SelectListItem {Text = "关闭", Value = "3"}};
}
 
            @using (Html.BeginForm("Index", "Bug", FormMethod.Get))
            {
                <table class="table_input" style="width: 100%;">
                    <tr>
                        <th style="width: 100px;">状态:</th>
                        <td style="width: 180px;"> 
                            @Html.DropDownList("status", statusList.InsertEmpty(), new { @class = "text-medium", style = "width: 99%;" })</td>
                        <th style="width: 100px;">关键字:</th>
                        <td style="width: 180px;">@Html.TextBox("keyword", "", new { @class = "text-medium", style = "width: 80%;" })</td>
                        <td>
                            <input type="submit" class="button-submit" value="查询" /></td>
                    </tr>
                </table>
            }
            @if (Model != null && Model.Any())
            {
                <table class="table_list" style="width: 99%;">
                    <tr>
                        <th style="width: 80px;">编码</th>
                        <th  style="width: 200px;">标题</th>
                        <th  >内容</th>
                        <th style="width: 60px;">提单人</th>
                        <th style="width: 60px;">状态</th>
                        <th style="width: 180px;">操作</th>
                    </tr>
                    @foreach (var item in Model)
                    {
                        <tr>
                            <td>@item.Id
                            </td>
                            <td   title="@item.Title">@item.Title.CutString(60)</td>
                            <td  title="@item.Content" >@item.Content.CutString(80)</td>
                            <td>@item.Name</td> 
                            <td>@statusList.First(x=>x.Value==item.Status.ToString(CultureInfo.InvariantCulture)).Text</td> 
                        <td class="action">    
                            @Html.ActionLinkEx("备注", "Remark", "Bug", new {id = item.Id, returnUrl = Request.RawUrl}, new {@class = ""})
                              @if (item.Status == 0)
                              {
                                 @Html.ActionLinkEx("已解决", "Status", "Bug", new {id = item.Id,status=1, returnUrl = Request.RawUrl}, new {@class = "delete"})
                                 @Html.ActionLinkEx("保留现状", "Status", "Bug", new {id = item.Id,status=2, returnUrl = Request.RawUrl}, new {@class = "delete"})
                                  
                              } 
                               @if (item.Status == 2 || item.Status == 1)
                              {
                                 @Html.ActionLinkEx("未解决", "Status", "Bug", new {id = item.Id,status=0, returnUrl = Request.RawUrl}, new {@class = "delete"})
                               @Html.ActionLinkEx("关闭", "Status", "Bug", new { id = item.Id,status=3, returnUrl = Request.RawUrl }, new { @class = "delete" })
                                  
                              } 
                              
                             
                            </td>
                        </tr>
                    }


                </table>
    
                <div class="page">
                    @Html.Pager("page", Model.PageSize, Model.TotalItems)
                </div>
            }
            else
            {
                <div class="empty">
                    查询信息为空
                </div>
            }
       @section Scripts {
    <script type="text/javascript">

        $(function () {
            $("a.delete").click(function () {
                return window.confirm("您确认要把当前问题修改为 "+$(this).html()+" 状态么?");

            });

        })

    </script>

}
